package packed_widgets

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/theme"
	"fyne.io/fyne/v2/widget"
)

type PopUp struct {
	*BaseComponent
	obj    *widget.PopUp
	width  float32
	height float32
}

func (popUp *PopUp) Show(content, parent fyne.CanvasObject) {
	popUp.obj = widget.NewPopUp(content, GetAppWindow().Canvas())
	popUp.obj.Resize(fyne.NewSize(popUp.width, popUp.height))
	popUp.obj.ShowAtRelativePosition(fyne.NewPos(0, theme.Padding()+parent.Size().Height), parent)
}

func (popUp *PopUp) Hide() {
	if popUp.obj != nil {
		popUp.obj.Hide()
	}
}

func NewPopUp(width, height float32) *PopUp {
	popUp := &PopUp{
		BaseComponent: NewBaseComponent(),
		width:         width,
		height:        height,
	}
	return popUp
}
